//index.js
//获取应用实例
var app = getApp()
var common = require('../../utils/common.js');
Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    systemInfo: {},
    status: true,
    msg: ""
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../meal/list/index'
    })
  },
  gotoTest: function(){
    var that = this;
    common.reqService("/exam/Candidate/Login", {"user_name": that.data.userInfo.nickName, "exam_id": 1}, that.data.systemInfo, function(data){
      
      if(data.code != "0"){
        common.toast(that, data.msg);
        return false;
      }
      common.toast(that, '登录成功!');
      wx.setStorageSync("user_token", data.data.token);
    });
  },
  hiddenToast: function(){
     this.setData({status: true, msg:''});
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
    app.getSystemInfo(function(systemInfo){
      //更新数据
      that.setData({
        systemInfo:systemInfo
      })
    })

    wx.navigateTo({
      url: '../meal/list/index'
    })
  }
})
